import axios from 'axios'
// import router from '../../../router'
import '../../../Mock/Li/payinf.js'


const state={
    List:[],//总数据
    L_Yong_list:[],//佣金记录的数据
}

const mutations={
    //佣金记录的初始数据
    L_yong_chu(state,data){
        state.List=data.lis
        const list=data.lis.slice((data.ind*data.num),(data.ind+1)*data.num)
        const liss=[]
        const lis=list.filter(item=>{
            liss.push({times:item.time.substring(0,4),item})
            return 
        })
        const lise=liss.sort((a,b)=>{
            return b.times-a.times
        })
        state.L_Yong_list=lise
    },
    //搜索用户
    L_yong_sou(state,data){
        const lis=state.List.filter(item=>{
            if(item.name.indexOf(data.name)>-1){
                return item
            }
        })
        const liss=[]
        const list=lis.filter(item=>{
            liss.push({times:item.time.substring(0,4),item})
            return 
        })
        const lise=liss.sort((a,b)=>{
            return b.times-a.times
        })
        state.L_Yong_list=lise
    }
}

const actions={
    async L_Yong_Chu({commit},data){
        const {num,ind}=data
        //佣金记录的初始数据
        const lis=await axios.get("/ips/L_yongchu")
        commit("L_yong_chu",{lis:lis.data.list,num,ind})
    },
    //佣金记录搜索
    async L_Yong_Sou({commit},data){
        commit("L_yong_sou",data)
    }
}

export default {
    namespaced:true,
    state,
    mutations,
    actions
}